package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TeacherManage;
import com.ruoyi.system.service.ITeacherManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教师一览Controller
 * 
 * @author ruoyi
 * @date 2024-06-05
 */
@RestController
@RequestMapping("/system/teacher")
public class TeacherManageController extends BaseController
{
    @Autowired
    private ITeacherManageService teacherManageService;

    /**
     * 查询教师一览列表
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeacherManage teacherManage)
    {
        startPage();
        List<TeacherManage> list = teacherManageService.selectTeacherManageList(teacherManage);
        return getDataTable(list);
    }

    /**
     * 导出教师一览列表
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:export')")
    @Log(title = "教师一览", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeacherManage teacherManage)
    {
        List<TeacherManage> list = teacherManageService.selectTeacherManageList(teacherManage);
        ExcelUtil<TeacherManage> util = new ExcelUtil<TeacherManage>(TeacherManage.class);
        util.exportExcel(response, list, "教师一览数据");
    }

    /**
     * 获取教师一览详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:query')")
    @GetMapping(value = "/{teacherId}")
    public AjaxResult getInfo(@PathVariable("teacherId") Long teacherId)
    {
        return success(teacherManageService.selectTeacherManageByTeacherId(teacherId));
    }

    /**
     * 新增教师一览
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:add')")
    @Log(title = "教师一览", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeacherManage teacherManage)
    {
        return toAjax(teacherManageService.insertTeacherManage(teacherManage));
    }

    /**
     * 修改教师一览
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:edit')")
    @Log(title = "教师一览", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeacherManage teacherManage)
    {
        return toAjax(teacherManageService.updateTeacherManage(teacherManage));
    }

    /**
     * 删除教师一览
     */
    @PreAuthorize("@ss.hasPermi('system:teacher:remove')")
    @Log(title = "教师一览", businessType = BusinessType.DELETE)
	@DeleteMapping("/{teacherIds}")
    public AjaxResult remove(@PathVariable Long[] teacherIds)
    {
        return toAjax(teacherManageService.deleteTeacherManageByTeacherIds(teacherIds));
    }
}
